cmake_minimum_required(VERSION 3.0)

#指定版本信息
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_BUILD_TYPE Release)

message("-- Build under the x86 platform")
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_C_COMPILER gcc)

#set(CMAKE_C_FLAGS "-std=gnu99 -g -rdynamic")
#set(CMAKE_CXX_FLAGS "-std=c++11 -g -rdynamic")
set(CMAKE_C_FLAGS "-std=gnu99 -O3")
set(CMAKE_CXX_FLAGS "-std=c++11 -O3")


project(test)

file(GLOB_RECURSE ALL_HEADERS
    ${PROJECT_SOURCE_DIR}/src/*.h
    ${PROJECT_SOURCE_DIR}/src/*.hpp
)

file(GLOB_RECURSE ALL_SOURCES 
    ${PROJECT_SOURCE_DIR}/src/*.cpp
    ${PROJECT_SOURCE_DIR}/src/*.cxx
    ${PROJECT_SOURCE_DIR}/src/*.cc
    ${PROJECT_SOURCE_DIR}/src/*.c
)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

include_directories(${PROJECT_SOURCE_DIR}/inc)
include_directories(${PROJECT_SOURCE_DIR}/src)
#link_libraries(${PROJECT_SOURCE_DIR}/lib)
link_directories(${PROJECT_SOURCE_DIR}/lib)

file(GLOB_RECURSE LIB_ThirdParty ${PROJECT_SOURCE_DIR}/lib/*.so)

add_executable(${PROJECT_NAME} ${ALL_SOURCES} ${ALL_HEADERS})

target_link_libraries(
    ${PROJECT_NAME}
    ${LIB_ThirdParty}
    dl
    m
    rt
    pthread
)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/lib DESTINATION ${EXECUTABLE_OUTPUT_PATH})
